
*** Set Fixed Effects and Clustering
global fe "courtq"
global clusvar "partyr"
global controls "female sh_hhpov lmrent logclaim notselfrep"

*******************************
***** First Stage Table *******
*******************************
** note for this table estsample was created from regressing credit scores for Q1-Q8 not 5-12 as above
capture frame drop fscredit 
frame create fscredit beta se str50 specification str35 coef_var N

ivreghdfe evictionorder stringency if samp==1 & all==1 & estsample==1, absorb($fe) cluster($clusvar)
frame post fscredit (_b[stringency]) (_se[stringency]) ("First Stage, No Controls") ("Coefficent on Instrument") (e(N))


ivreghdfe evictionorder stringency $controls if samp==1 & all==1 & estsample==1 , absorb($fe) cluster($clusvar)
frame post fscredit (_b[stringency]) (_se[stringency]) ("First Stage, With Controls") ("Coefficent on Instrument") (e(N))

frame fscredit : saveold ${Inputs}/NY_credit_fs.dta, replace

*******************************
**** Summary Stats Table ******
*******************************
capture frame drop  creditsumstat 
frame create creditsumstat mean sd str50 specification str50 outcome N
** Female
sum female if evictionorder==1 & estsample==1
frame post creditsumstat (`r(mean)') (`r(sd)') ("Evicted") ("Female") (`r(N)')
sum female if evictionorder==0 & estsample==1
frame post creditsumstat (`r(mean)') (`r(sd)') ("Not Evicted") ("Female") (`r(N)')

** Index
sum indx_pre if evictionorder==1 & estsample==1
frame post creditsumstat (`r(mean)') (`r(sd)') ("Evicted") ("Index") (`r(N)')
sum indx_pre if evictionorder==0 & estsample==1
frame post creditsumstat (`r(mean)') (`r(sd)') ("Not Evicted") ("Index") (`r(N)')

** Credit Score
sum pre_avg_creditscore if evictionorder==1 & estsample==1
frame post creditsumstat (`r(mean)') (`r(sd)') ("Evicted") ("Credit Score") (`r(N)')
sum pre_avg_creditscore if evictionorder==0 & estsample==1
frame post creditsumstat (`r(mean)') (`r(sd)') ("Not Evicted") ("Credit Score") (`r(N)')

** No Open Revolving Account
sum pre_avg_zerorevolving if evictionorder==1 & estsample==1
frame post creditsumstat (`r(mean)') (`r(sd)') ("Evicted") ("No Revolving Account") (`r(N)')
sum pre_avg_zerorevolving if evictionorder==0 & estsample==1
frame post creditsumstat (`r(mean)') (`r(sd)') ("Not Evicted") ("No Revolving Account") (`r(N)')

** Deliquencies and Collections
sum pre_avg_deliquency if evictionorder==1 & estsample==1
frame post creditsumstat (`r(mean)') (`r(sd)') ("Evicted") ("Deliquencies and Collections") (`r(N)')
sum pre_avg_deliquency if evictionorder==0 & estsample==1
frame post creditsumstat (`r(mean)') (`r(sd)') ("Not Evicted") ("Deliquencies and Collections") (`r(N)')

** No Auto Loan or Lease
sum preany_avg_autoloan if evictionorder==1 & estsample==1
frame post creditsumstat (`r(mean)') (`r(sd)') ("Evicted") ("Any Auto Loan") (`r(N)')
sum preany_avg_autoloan if evictionorder==0 & estsample==1
frame post creditsumstat (`r(mean)') (`r(sd)') ("Not Evicted") ("Any Auto Loan") (`r(N)')


frame creditsumstat : saveold "${Inputs}/NY_credit_sumstats.dta", replace

frame change default